package com.woniuxy01;

import java.util.Scanner;

/**
 * @author 作者
 * @create 2025-05-27 9:27
 */
public class Test01 {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String answer;
        int userShow = 0;
        String userShowName = "";
        int computerShow = 0;
        String computerShowName = "";

        int count = 0;
        int userWin = 0;
        int computerWin = 0;
        MyUitl myUitl = new MyUitl();
        //开始游戏
        do {
            count++;
            //用户出拳
            boolean flag;
            userShow= myUitl.userShow();
            //显示用户出拳
            userShowName = myUitl.showFistName(userShow);
            //电脑出拳
            computerShow = myUitl.computerShow();
            //显示电脑出拳
            computerShowName = myUitl.showFistName(computerShow);
            System.out.println("用户输入：" + userShowName);
            System.out.println("电脑输入：" + computerShowName);
            //判断胜负
            if ((userShow == 1 && computerShow == 3) || (userShow == 2 && computerShow == 1) || (userShow == 3 && computerShow == 2)) {
                userWin++;
                System.out.println("用户获胜");
            } else if (userShow == computerShow) {
                System.out.println("平局");
            } else {
                computerWin++;
                System.out.println("电脑获胜");
            }
            System.out.println("是否继续下一局");
            answer = sc.next();
        } while (answer.equals("y"));
        //总成绩:最终胜负
        System.out.println("对战次数:" + count);
        System.out.println("用户获胜:" + userWin);
        System.out.println("电脑获胜:" + computerWin);
        if (userWin > computerWin) {
            System.out.println("用户最终获胜");
        } else if (computerWin > userWin) {
            System.out.println("电脑最终获胜");
        } else {
            System.out.println("打平");
        }
        System.out.println("游戏结束");
    }


}
